package com.cpi.cornpp.purchaseorder.spot.services;

import java.util.List;

import com.cpi.cornpp.common.exception.CornPPException;
import com.cpi.cornpp.purchaseorder.spot.converter.PurchaseOrderSpotConverter;
import com.cpi.cornpp.purchaseorder.spot.dao.PurchaseOrderSpotDAO;
import com.cpi.cornpp.purchaseorder.spot.exception.PurchaseOrderSpotException;
/**
 * Purchase Order Sport Service
 * @author Edgar Joao
 *
 */
public class PurchaseOrderSpotService {
	/**
	 * 
	 * @param purchaseOrderId
	 * @return
	 * @throws PurchaseOrderSpotException
	 */
	public List getPurchaseOrderSpot(int purchaseOrderId) throws PurchaseOrderSpotException{
		PurchaseOrderSpotDAO purchaseOrderSpotDAO = null;
		PurchaseOrderSpotConverter purchaseOrderSpotConverter = null;		
		List list = null;
		try{			
			purchaseOrderSpotDAO = new PurchaseOrderSpotDAO();
			purchaseOrderSpotConverter = new PurchaseOrderSpotConverter();				
			list = purchaseOrderSpotConverter.convertDTOsToViews(purchaseOrderSpotDAO.getPurchaseOrderSpot(purchaseOrderId));												
		} catch (PurchaseOrderSpotException purchaseOrderSpotException) {
			throw purchaseOrderSpotException;
		} catch (Exception e){
			PurchaseOrderSpotException purchaseOrderSpotException = null;
			e.printStackTrace(System.out);
			purchaseOrderSpotException = new PurchaseOrderSpotException(e , CornPPException.LAYER_SERVICE,CornPPException.ACTION_LISTS);
			throw purchaseOrderSpotException;
		}
		return list;		
	}
}
